Skip to content

Fix audit gaps: URL validation, curl timeouts, heartbeat backoff, health response - #4

Merged
diskhacker merged 1 commit into
mainfrom
claude/conversation-summary-UT2b8
Apr 12, 2026
Merged

Fix audit gaps: URL validation, curl timeouts, heartbeat backoff, health response#4
diskhacker merged 1 commit into
mainfrom
claude/conversation-summary-UT2b8

Conversation

@diskhacker

@diskhacker diskhacker commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add URL validation in sigops.http (reject invalid schemes, control chars)
  • Add curl timeouts (--max-time 30/10, --connect-timeout 5)
  • Add heartbeat retry with exponential backoff (2s-60s, max 5 retries)
  • Make Slack webhookUrl required (remove placeholder)
  • Add agent_id to health endpoint JSON response
  • Capture response body in HTTP tool output
  • 35 tests passing, clippy clean

Test plan

  • cargo test — 35 tests passing
  • cargo clippy -- -D warnings — zero warnings
  • URL validation: 4 new tests
  • Timeout flags: 2 new tests
  • Backoff calculation: 1 new test

https://claude.ai/code/session_016BNDbB5ERJFsXQZiuL6tL1

Summary by CodeRabbit

  • New Features

    • Heartbeat sending now automatically retries with exponential backoff (up to 5 attempts) on failure
    • HTTP requests now return response body alongside status code
  • Bug Fixes

    • HTTP requests now validate and reject invalid URL schemes and control characters
    • Slack notifications now require a valid webhook URL (no fallback)
  • Improvements

    • Added timeout configuration for HTTP and Slack notification requests
    • Health endpoint response now includes agent identifier

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 722319b3-704b-4616-9a9e-38d74618b31d

📥 Commits

Reviewing files that changed from the base of the PR and between 2e21296 and 2a5e179.

📒 Files selected for processing (4)
  • src/executor.rs
  • src/health.rs
  • src/heartbeat.rs
  • src/main.rs

📝 Walkthrough

Walkthrough

The changes enhance HTTP request handling with URL validation and response body capture, add exponential backoff retry logic for heartbeat transmission, propagate agent ID through the health endpoint, and enforce timeout constraints on external service calls.

Changes

Cohort / File(s) Summary
HTTP Request & Slack Notification Validation
src/executor.rs
Added validate_url() to reject URLs with invalid schemes or control characters; changed execute_http_sync to capture response body and parse status code separately; tightened execute_notify_slack to require webhookUrl and added curl timeout flags; expanded tests for invalid URLs, missing webhook, and response parsing logic.
Heartbeat Resilience
src/heartbeat.rs, src/main.rs
Introduced backoff_delay_secs() for exponential backoff capped at 60 seconds and MAX_CONSECUTIVE_FAILURES constant; added send_heartbeat_with_retry() method with retry loop and failure logging; updated main heartbeat transmission to use the new retry variant.
Health Endpoint Enhancement
src/health.rs, src/main.rs
Extended serve_health() to accept and include agent_id in JSON response; updated health server startup call to pass cloned agent ID.

Sequence Diagram

sequenceDiagram
    participant Agent as Agent Loop
    participant HB as HeartbeatClient
    participant Service as Heartbeat Service
    participant Logger as Logging System

    Agent->>HB: send_heartbeat_with_retry()
    loop Attempt 1 to MAX_CONSECUTIVE_FAILURES
        HB->>Service: send_heartbeat()
        alt Success
            Service-->>HB: HeartbeatResponse
            HB-->>Agent: return Ok(response)
        else Failure
            Service-->>HB: HeartbeatError
            HB->>Logger: warn!(last error)
            alt Max Retries Reached
                HB->>Logger: warn!(max retries exceeded)
                HB->>Logger: error!(exhausted retries)
                HB-->>Agent: return Err(last_error)
            else More Retries Available
                HB->>HB: sleep(backoff_delay_secs(attempt))
                Note over HB: Exponential delay: 2^(attempt+1),<br/>capped at 60 seconds
            end
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Hop hop, now URLs are checked,
Response bodies? Fully wrecked!
Retries bounce with exponential grace,
Agent ID marks its special place! 🎯
Validation and resilience, oh what a race!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: URL validation, curl timeouts, heartbeat backoff, and health response improvements—all key audit fixes present in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/conversation-summary-UT2b8

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…ealth agent_id, response body capture

- Add URL validation in sigops.http: reject non-http(s) schemes, newlines, null bytes, control chars
- Add curl timeouts: --max-time 30 / --connect-timeout 5 for HTTP, --max-time 10 / --connect-timeout 5 for Slack
- Add heartbeat retry with exponential backoff (2s, 4s, 8s, 16s, max 60s, 5 max retries)
- Make webhookUrl required for sigops.notify_slack (remove placeholder default)
- Add agent_id to health endpoint JSON response
- Capture response body in HTTP tool using curl -w "\n%{http_code}" pattern
- Add comprehensive tests: URL validation, timeout flags, webhook requirement, body parsing, backoff calc

https://claude.ai/code/session_016BNDbB5ERJFsXQZiuL6tL1
@diskhacker
diskhacker force-pushed the claude/conversation-summary-UT2b8 branch from 2e21296 to 2a5e179 Compare April 12, 2026 11:25
@diskhacker
diskhacker merged commit e902d68 into main Apr 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants